# 给定一个列表, 根据`grade`来排序
from pprint import pprint
classes1= [
    {"name": "n_1", "age": 11, "grade": "A"},
    {"name": "n_88", "age": 22, "grade": "B"},
    {"name": "n_3", "age": 99, "grade": "A"},
    {"name": "n_6", "age": 44, "grade": "A"},
    {"name": "n_5", "age": 33, "grade": "C"},
    {"name": "n_77", "age": 66, "grade": "D"},
    {"name": "n_7", "age": 77, "grade": "A"},
]
pprint(classes1)
s_grade=sorted(classes1, key=lambda x: x.get('grade') ) # sort by grade
s_name=sorted(classes1, key=lambda x: x.get('name') ) # sort by name
s_age=sorted(classes1, key=lambda x: x.get('age') ) # sort by age


print("after:---s_grade")
pprint(s_grade)

print("after:---s_age")
pprint(s_age)

print("after:---s_name")
pprint(s_name)
